home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 125 / MOBICLIC 125.ISO / pc / DATA / HOTE / prod_gen_XB / moteur.swf / scripts / frame_1 / DoAction.as
Text File  |  2010-06-15  |  15KB  |  533 lines

  1. function gimme2digits(X)
  2. {
  3.    if(Number(X) < 10)
  4.    {
  5.       lX = "0" + Number(X);
  6.    }
  7.    else
  8.    {
  9.       lX = String(X);
  10.    }
  11.    return lX;
  12. }
  13. function gimme3digits(X)
  14. {
  15.    if(Number(X) < 10)
  16.    {
  17.       lX = "00" + Number(X);
  18.    }
  19.    else if(Number(X) < 100)
  20.    {
  21.       lX = "0" + Number(X);
  22.    }
  23.    else
  24.    {
  25.       lX = String(X);
  26.    }
  27.    return lX;
  28. }
  29. function randomValue(min, max)
  30. {
  31.    var _loc1_ = Math.floor(Math.random() * (max - min + 1)) + min;
  32.    return _loc1_;
  33. }
  34. function InitMascotte(p)
  35. {
  36.    trace("InitMascotte " + this);
  37.    var _loc3_ = this.MediasExternes[p.mc._name].ParamsXml;
  38.    var _loc4_ = p.mc;
  39.    _loc4_.ParamsXml = this.MediasExternes[_loc4_._name].ParamsXml;
  40.    trace("this.MediasExternes : " + _root.MediasExternes);
  41.    trace("mascotte._name : " + _loc4_._name);
  42.    trace("this.MediasExternes[mascotte._name].ParamsXml : " + this.MediasExternes[_loc4_._name].ParamsXml);
  43.    trace("this.MediasExternes[mascotte._name] : " + this.MediasExternes[_loc4_._name]);
  44.    _loc4_._x = _loc3_.x != undefined ? _loc3_.x : 0;
  45.    trace("params_xml.x : " + _loc3_.x);
  46.    _loc4_._y = _loc3_.y != undefined ? _loc3_.y : 0;
  47.    trace("params_xml.y : " + _loc3_.y);
  48.    _loc4_._xscale = _loc3_.scale != undefined ? Number(_loc3_.scale) : 100;
  49.    trace("params_xml.scale : " + _loc3_.scale);
  50.    _loc4_._yscale = _loc3_.scale != undefined ? Math.abs(Number(_loc3_.scale)) : 100;
  51.    trace("params_xml.scale : " + _loc3_.scale);
  52.    return _loc4_;
  53. }
  54. function afficherMascottes(mascottes)
  55. {
  56.    var _loc2_ = 0;
  57.    while(_loc2_ < _root.MASCOTTES_LISTE.length)
  58.    {
  59.       _root.MASCOTTES_LISTE[_loc2_]._visible = false;
  60.       _root.MASCOTTES_LISTE[_loc2_].ETAT = "E2";
  61.       _loc2_ = _loc2_ + 1;
  62.    }
  63.    if(mascottes != undefined)
  64.    {
  65.       var _loc4_ = undefined;
  66.       _loc2_ = 0;
  67.       while(_loc2_ < mascottes.length)
  68.       {
  69.          _loc4_ = _root["MASC_" + mascottes[_loc2_].nom];
  70.          _loc4_.ETAT = mascottes[_loc2_].action;
  71.          trace("mascottes[i].action : " + mascottes[_loc2_].action);
  72.          _loc4_.gotoAndStop(mascottes[_loc2_].action);
  73.          _root.InitMascotte({mc:_loc4_});
  74.          _loc4_._visible = true;
  75.          _loc2_ = _loc2_ + 1;
  76.       }
  77.    }
  78. }
  79. function testeDebutCommentSpecial()
  80. {
  81.    var _loc2_ = _root.gCommentOn.id.split("_")[_root.gCommentOn.id.split("_").length - 1];
  82.    switch(_loc2_)
  83.    {
  84.       case "bz":
  85.       case "BZ":
  86.          trace("-------  BZ on-----------");
  87.          _root.DesactiveOEIL();
  88.          if(_root.BT_OEIL.gEtat !== 3)
  89.          {
  90.             trace("E3");
  91.             _root.BT_OEIL.gotoAndPlay("E3");
  92.          }
  93.          else
  94.          {
  95.             trace("PARLE");
  96.             _root.BT_OEIL.OEIL_P.gotoAndPlay("parle");
  97.          }
  98.          break;
  99.       case "ze":
  100.       case "ZE":
  101.          trace("-------  ZE on-----------");
  102.          _root.DesactiveOEIL();
  103.          if(_root.BT_OEIL.gEtat !== 3)
  104.          {
  105.             _root.BT_OEIL.gotoAndPlay("E3");
  106.          }
  107.          else
  108.          {
  109.             _root.BT_OEIL.OEIL_P.gotoAndPlay("parle");
  110.          }
  111.          _root.afficherRolls();
  112.          break;
  113.       case "sp":
  114.       case "SP":
  115.          trace("-------  SP on-----------");
  116.          _root.MASCOTTE_SPAM.gotoAndStop("E1");
  117.          _root.MASCOTTE_SPAM._visible = true;
  118.          break;
  119.       case "wk":
  120.       case "WK":
  121.          trace("-------  WK on-----------");
  122.          trace("-------  MASCOTTE_WIKI-----------");
  123.          _root.MASCOTTE_WIKI.gotoAndStop("E1");
  124.          _root.MASCOTTE_WIKI._visible = true;
  125.          break;
  126.       case "bg":
  127.       case "BG":
  128.          trace("-------  BG on-----------");
  129.          _root.MASCOTTE_BUG.gotoAndStop("E1");
  130.          _root.MASCOTTE_BUG._visible = true;
  131.    }
  132. }
  133. function testeFinCommentSpecial()
  134. {
  135.    var _loc2_ = _root.gCommentOn.id.split("_")[_root.gCommentOn.id.split("_").length - 1];
  136.    switch(_loc2_)
  137.    {
  138.       case "bz":
  139.       case "BZ":
  140.          trace("-------  BZ off-----------");
  141.          _root.ActiveOEIL();
  142.          _root.BT_OEIL.OEIL_P.gotoAndPlay("rentre");
  143.          _root.BT_OEIL.gClicOn = undefined;
  144.          break;
  145.       case "ze":
  146.       case "ZE":
  147.          trace("-------  ZE off-----------");
  148.          _root.ActiveOEIL();
  149.          _root.BT_OEIL.OEIL_P.gotoAndPlay("rentre");
  150.          _root.BT_OEIL.gClicOn = undefined;
  151.          _root.masquerRolls();
  152.          break;
  153.       case "sp":
  154.       case "SP":
  155.          trace("-------  SP off-----------");
  156.          _root.MASCOTTE_SPAM.gotoAndStop("E2");
  157.          if(_root.MASCOTTE_SPAM.CacherApres != false)
  158.          {
  159.             _root.MASCOTTE_SPAM._visible = false;
  160.          }
  161.          break;
  162.       case "wk":
  163.       case "WK":
  164.          trace("-------  WK off-----------");
  165.          _root.MASCOTTE_WIKI.gotoAndStop("E2");
  166.          if(_root.MASCOTTE_WIKI.CacherApres != false)
  167.          {
  168.             _root.MASCOTTE_WIKI._visible = false;
  169.          }
  170.          break;
  171.       case "bg":
  172.       case "BG":
  173.          trace("-------  BG off-----------");
  174.          _root.MASCOTTE_BUG.gotoAndStop("E2");
  175.          if(_root.MASCOTTE_BUG.CacherApres != false)
  176.          {
  177.             _root.MASCOTTE_BUG._visible = false;
  178.          }
  179.    }
  180. }
  181. function activePause()
  182. {
  183.    trace("paused ?");
  184.    activePauseSons();
  185.    activePauseClip(gClipGen);
  186.    activePauseInterval();
  187. }
  188. function activePauseSons()
  189. {
  190.    trace("active pause");
  191.    if(gCommentOn !== undefined)
  192.    {
  193.       gCommentOnPause = gCommentOn;
  194.       gCommentOnPause.p = gCommentOn.p;
  195.       xtrace("++++++++ " + gCommentOn.p);
  196.       gCommentOnPausePos = gCommentOn.position;
  197.       stopComment();
  198.    }
  199.    if(gListeBruitage !== undefined)
  200.    {
  201.       gListePosBruitage = [];
  202.       gListeBruitageP = [];
  203.       i = gListeBruitage.length - 1;
  204.       while(i >= 0)
  205.       {
  206.          var _loc1_ = gListePosBruitage.push[soundObjects[gBruitageName + gListeBruitage[i]].position];
  207.          gListeBruitageP.push[soundObjects[gBruitageName + gListeBruitage[i]].p];
  208.          stopBruitage(soundObjects[gBruitageName + gListeBruitage[i]].p);
  209.          i--;
  210.       }
  211.    }
  212.    if(gMusicOn)
  213.    {
  214.       gPosMusic = soundObjects[gMusic].position;
  215.       soundObjects[gMusic].stop();
  216.    }
  217. }
  218. function desactivePause()
  219. {
  220.    desactivePauseSons();
  221.    desactivePauseClip();
  222.    desactivePauseInterval();
  223. }
  224. function desactivePauseSons()
  225. {
  226.    if(gCommentOnPausePos !== undefined)
  227.    {
  228.       if(gCommentOnPause.duration / 1000 !== gCommentOnPausePos / 1000)
  229.       {
  230.          joueSon(gCommentOnPause.p);
  231.       }
  232.    }
  233.    if(gMusicOn)
  234.    {
  235.       soundObjects[gMusic].start(0,2000);
  236.       gPosMusic = undefined;
  237.    }
  238. }
  239. function findClipAnimRecursive(lClip, ListeClipAnim)
  240. {
  241.    for(var _loc3_ in lClip)
  242.    {
  243.       if(typeof lClip[_loc3_] == "movieclip")
  244.       {
  245.          if(getPos(gListeClipPause,lClip[_loc3_]) == -1)
  246.          {
  247.             gListeClipPause.push(lClip[_loc3_]);
  248.             gListeClipPauseFrame.push(lClip[_loc3_]._currentframe);
  249.             var _loc2_ = lClip[_loc3_];
  250.             findClipAnimRecursive(_loc2_);
  251.          }
  252.       }
  253.    }
  254. }
  255. function compareClipFrame(lClip)
  256. {
  257.    var _loc1_ = 0;
  258.    while(_loc1_ < gListeClipPause.length)
  259.    {
  260.       if(gListeClipPauseFrame[_loc1_] == gListeClipPause[_loc1_]._currentframe)
  261.       {
  262.          gListeClipPauseJoueur.push(0);
  263.       }
  264.       else
  265.       {
  266.          trace(gListeClipPause[_loc1_] + " _ " + gListeClipPauseFrame[_loc1_] + " _ " + gListeClipPause[_loc1_]._currentframe);
  267.          gListeClipPauseJoueur.push(1);
  268.       }
  269.       gListeClipPause[_loc1_].gotoAndStop(gListeClipPauseFrame[_loc1_]);
  270.       _loc1_ = _loc1_ + 1;
  271.    }
  272. }
  273. function activePauseClip(lClip)
  274. {
  275.    gListeClipPause = [];
  276.    gListeClipPauseFrame = [];
  277.    gListeClipPauseJoueur = [];
  278.    lClip.pFrame = 0;
  279.    lClip.onEnterFrame = function()
  280.    {
  281.       this.pFrame += 1;
  282.       switch(this.pFrame)
  283.       {
  284.          case 1:
  285.             findClipAnimRecursive(this);
  286.             break;
  287.          case 2:
  288.             compareClipFrame(this);
  289.             delete this.onEnterFrame;
  290.             mcPause = creerRectangle({nom:"mcPause",pere:_root,level:15001,width:gWidth,height:gHeight,x:0,y:0,alpha:0});
  291.             mcPause.useHandCursor = false;
  292.             mcPause.onPress = function()
  293.             {
  294.             };
  295.       }
  296.    };
  297. }
  298. function desactivePauseClip()
  299. {
  300.    var _loc1_ = 0;
  301.    while(_loc1_ < gListeClipPause.length)
  302.    {
  303.       if(gListeClipPauseJoueur[_loc1_] == 1)
  304.       {
  305.          gListeClipPause[_loc1_].gotoAndPlay(gListeClipPauseFrame[_loc1_]);
  306.       }
  307.       else
  308.       {
  309.          gListeClipPause[_loc1_].gotoAndStop(gListeClipPauseFrame[_loc1_]);
  310.       }
  311.       _loc1_ = _loc1_ + 1;
  312.    }
  313.    gListeClipPause = undefined;
  314.    gListeClipPauseFrame = undefined;
  315.    gListeClipPauseJoueur = undefined;
  316. }
  317. function spacePause()
  318. {
  319.    if(gPauseOn == undefined)
  320.    {
  321.       trace("PAUSE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ");
  322.       activePause();
  323.       gPauseOn = 1;
  324.    }
  325.    else
  326.    {
  327.       trace("ARRETE LA PAUSE !!!!!!!!!!!!!!!!!!!!! ");
  328.       removeMovieClip(mcPause);
  329.       desactivePause();
  330.       gPauseOn = undefined;
  331.    }
  332. }
  333. function playClipAnim(lClip)
  334. {
  335.    playClipAnimRecursive(lClip,[]);
  336. }
  337. this.CIBLE = _root;
  338. _global.gimme2digits = gimme2digits;
  339. _global.gimme3digits = gimme3digits;
  340. _global.randomValue = randomValue;
  341. _root.InitMascotte = InitMascotte;
  342. _root.afficherMascottes = afficherMascottes;
  343. var CIBLE = _root;
  344. this.xPauseOn = function()
  345. {
  346.    trace("xPauseOn " + this + " " + _global.pauseComment);
  347.    _global.pauseComment();
  348.    this.moteur.PauseMCs = [];
  349.    this.moteur.xPause_rec({clipref:_root});
  350. };
  351. this.xPauseOff = function()
  352. {
  353.    trace("xPauseOff " + this);
  354.    this.moteur.PauseDesactive();
  355.    _global.continueComment();
  356. };
  357. this.PAUSEINTFUNC = function()
  358. {
  359.    var _loc3_ = getTimer();
  360.    if(_loc3_ - this.firstTime >= 100)
  361.    {
  362.       clearInterval(this.PAUSEINT);
  363.       this.xPause_rec2({clipref:_root});
  364.    }
  365. };
  366. this.xPause_rec = function(p)
  367. {
  368.    for(prop in p.clipref)
  369.    {
  370.       if(typeof p.clipref[prop] == "movieclip" && p.clipref[prop] != _root && p.clipref[prop].NoPause != true)
  371.       {
  372.          p.clipref[prop].DetectFrameFirst = p.clipref[prop]._currentframe;
  373.          this.xPause_rec({clipref:p.clipref[prop]});
  374.       }
  375.    }
  376.    if(p.clipref == _root)
  377.    {
  378.       this.firstTime = getTimer();
  379.       this.PAUSEINT = setInterval(this,"PAUSEINTFUNC",10);
  380.    }
  381. };
  382. this.xPause_rec2 = function(p)
  383. {
  384.    for(prop in p.clipref)
  385.    {
  386.       if(typeof p.clipref[prop] == "movieclip" && p.clipref[prop] != _root && p.clipref[prop].NoPause != true)
  387.       {
  388.          p.clipref[prop].DetectFrameLast = p.clipref[prop]._currentframe;
  389.          if(p.clipref[prop].DetectFrameLast != p.clipref[prop].DetectFrameFirst)
  390.          {
  391.             this.PauseMCs.push(p.clipref[prop]);
  392.          }
  393.          this.xPause_rec2({clipref:p.clipref[prop]});
  394.       }
  395.    }
  396.    if(p.clipref == _root)
  397.    {
  398.       this.PauseActive();
  399.    }
  400. };
  401. this.PauseActive = function()
  402. {
  403.    trace("PAUSEACTIVE " + this.PauseMCs.length);
  404.    for(prop in this.PauseMCs)
  405.    {
  406.       trace(this.PauseMCs[prop]);
  407.       this.PauseMCs[prop].stop();
  408.    }
  409. };
  410. this.PauseDesactive = function()
  411. {
  412.    trace("PAUSEDESACTIVE " + this.PauseMCs.length);
  413.    for(prop in this.PauseMCs)
  414.    {
  415.       trace(this.PauseMCs[prop]);
  416.       this.PauseMCs[prop].play();
  417.    }
  418. };
  419. this.CIBLE = _root;
  420. if(_global.gDataPath == undefined)
  421. {
  422.    _global.gDataPath = "../../";
  423. }
  424. this.ChargeMoteur = function(p)
  425. {
  426.    _root.moduleXmlRoot = _global.moduleXmlRoot;
  427.    trace("_ChargeMoteur() - Chargement du moteur (prod/moteur/main.as)" + _root);
  428.    _root.gModulePath = GetFilePath(this.CIBLE._url) + "/";
  429.    trace("_root.gModulePath : " + _root.gModulePath);
  430.    if(!_root.moduleOnline)
  431.    {
  432.       _root.XmlStocker = new XML();
  433.       _root.XmlStocker.ignoreWhite = true;
  434.       _root.XmlStocker.load(_root.gModulePath + "localConfig.xml");
  435.       _root.XmlStocker.onLoad = _root.onlocalConfigLoaded;
  436.    }
  437.    else
  438.    {
  439.       _root.Main();
  440.    }
  441. };
  442. _root.ChargeMoteur = this.ChargeMoteur;
  443. this.CIBLE.onlocalConfigLoaded = function(success)
  444. {
  445.    trace("onlocalConfigLoaded " + this);
  446.    if(success)
  447.    {
  448.       _root.moduleXmlRoot = _root.gModulePath + this.firstChild.attributes.src;
  449.       _root.Main();
  450.    }
  451. };
  452. this.CIBLE.Main = function()
  453. {
  454.    trace(this.CIBLE);
  455.    this.CIBLE.moduleInfo = _root.moduleInfo = new prod.moteur.V000xb_ChargementXML(this.CIBLE,_root.moduleXmlRoot,_root.moduleOnline);
  456. };
  457. this.CIBLE.xmlLoaded = function()
  458. {
  459.    trace("__xmlLoaded() " + this.CIBLE);
  460.    _global.HOTE.LoadingProgress(70);
  461.    this.initGen();
  462.    this.gModuleName = this.moduleInfo.returnNodeByPath("BackOffice").firstChild.attributes.id;
  463.    this.gCommentName = "S_" + this.gLangue + "_" + this.gModuleName + "_";
  464.    this.gBruitageName = "B_" + this.gModuleName + "_";
  465.    this.gImagesPath = this.gModulePath + "/I_" + this.gModuleName;
  466.    var _loc3_ = this.gModuleName.split("_");
  467.    this.gModuleNumber = Number(_loc3_[_loc3_.length - 1]);
  468.    trace("this.gModuleNumber : " + this.gModuleNumber);
  469.    this.gRubriqueName = _loc3_[0].substr(0,3);
  470.    trace("this.gRubriqueName : " + this.gRubriqueName);
  471.    this.gCdName = _loc3_[0].substr(3,3);
  472.    trace("this.gCdName : " + this.gCdName);
  473.    this.mediaChargeur = new prod.moteur.V006_ChargementMedias(this.CIBLE,this.CIBLE.moduleInfo,this.CIBLE.moduleOnline);
  474.    this.gereTextes = new prod.moteur.V014_GereTextes(this.CIBLE,this.CIBLE.moduleInfo);
  475. };
  476. this.CIBLE.mediaLoaded = function()
  477. {
  478.    if(typeof this.mediaChargeur == "undefined")
  479.    {
  480.       this.OnlySoundExterneHack = setInterval(this,"mediaLoaded",20);
  481.    }
  482.    else
  483.    {
  484.       trace("__mediaLoaded()");
  485.       this.soundObjects = this.mediaChargeur.returnSoundObject();
  486.       clearInterval(this.OnlySoundExterneHack);
  487.       this.initModule();
  488.    }
  489. };
  490. this.CIBLE.initModule = function()
  491. {
  492.    trace("__initModule()" + this.CIBLE + " _ " + this.CIBLE.initVariables);
  493.    _global.HOTE.LoadingProgress(90);
  494.    this.CIBLE.initVariables();
  495. };
  496. _root.initKeyPause = function()
  497. {
  498.    gPauseOn = 0;
  499.    gPauseSpaceOn = 0;
  500.    gPauseSpaceEnCours = 0;
  501. };
  502. _root.initGen = function()
  503. {
  504.    _root.gClipGen = _global.gClipGen = this;
  505.    trace("______________________________ " + this);
  506.    Stage.showMenu = false;
  507.    this.gLangue = "FR";
  508.    this.gMusicOn = 1;
  509.    this.gSousTitre = 0;
  510.    this.gST = 0;
  511.    this.gVolume = 100;
  512.    this.gWidth = moduleInfo.returnNodeByPath("BackOffice").firstChild.attributes.width;
  513.    this.gHeight = moduleInfo.returnNodeByPath("BackOffice").firstChild.attributes.height;
  514.    if(this.gWidth == undefined)
  515.    {
  516.       this.gWidth = 800;
  517.    }
  518.    else
  519.    {
  520.       this.gWidth = Number(this.gWidth);
  521.    }
  522.    if(this.gHeight == undefined)
  523.    {
  524.       this.gHeight = 600;
  525.    }
  526.    else
  527.    {
  528.       this.gHeight = Number(this.gHeight);
  529.    }
  530.    initKeyPause();
  531. };
  532. stop();
  533.